import { computed, ref } from 'vue'

let _isWide = ref(false)

export const isWide = computed(() => {
  uni.onWindowResize((res) => {
    _isWide.value = res.size.windowWidth > 768
  })
  return _isWide.value
})

export let startWide = false
export const setStartWide = (val: boolean) => {
  startWide = val
}

export const fontSize = computed(() => {
  let res = 0
  if (startWide) {
    res = isWide.value ? 30 : 60
  } else {
    res = isWide.value ? 15 : 30
  }
  return res
})

export const cellWidth = computed(() => {
  let res = 0
  if (startWide) {
    res = isWide.value ? 120 : 240
  } else {
    res = isWide.value ? 60 : 120
  }
  return res
})

export const inCellWidth = computed(() => {
  let res = 0
  if (startWide) {
    res = isWide.value ? 120 : 120
  } else {
    res = isWide.value ? 120 : 120
  }
  return res 
})

export const minTableWidth = computed(() => {
  let res = 0
  if (startWide) {
    res = isWide.value ? 2050 : 1025
  } else {
    res = isWide.value ? 1080 : 1025
  }
  return res 
})

export const imgHeight = computed(() => {
  let res = 0
  if (startWide) {
    res = isWide.value ? 600 : 220
  } else {
    res = isWide.value ? 600 : 220
  }
  return res
})

export const imgWidth = computed(() => {
  let res = 0
  if (startWide) {
    res = isWide.value ? 1940 : 600
  } else {
    res = isWide.value ? 1940 : 600
  }
  return res 
})